// 保存到本地
// token 3个操作 - 存储/获取/删除
const HMTT_TOKEN = 'HMTT_TOKEN'
// 1. 存储 token
export const setToken = (val) => localStorage.setItem(HMTT_TOKEN, val)
// 2. 获取 token - 注意这里没有写花括号，因为要 return 获取到的 token
export const getToken = () => localStorage.getItem(HMTT_TOKEN)
// 3. 删除 token
export const removeToken = () => localStorage.removeItem(HMTT_TOKEN)
// 🔔小技巧：手打上面封装的函数名，VsCode 会有自动导入的提示。

// 已关注栏目 - 本地 3个操作 - 存储/获取/删除
const HMTT_FOLLOW_CATE = 'HMTT_FOLLOW_CATE'
export const setCate = (val) => localStorage.setItem(HMTT_FOLLOW_CATE, JSON.stringify(val))
export const getCate = () => JSON.parse(localStorage.getItem(HMTT_FOLLOW_CATE)) || []
export const removeCate = () => localStorage.removeItem(HMTT_FOLLOW_CATE)

// 未关注栏目
const HMTT_UNFOLLOW_CATE = 'HMTT_UNFOLLOW_CATE'
export const setUnCate = (val) => localStorage.setItem(HMTT_UNFOLLOW_CATE, JSON.stringify(val))
export const getunCate = () => JSON.parse(localStorage.getItem(HMTT_UNFOLLOW_CATE)) || []
export const removeUnCate = () => localStorage.removeItem(HMTT_UNFOLLOW_CATE)

// 存储用户id - 本地 3个操作 - 存储/获取/删除
const HMTT_USER_ID = 'HMTT_USER_ID'
export const setUserId = (val) => localStorage.setItem(HMTT_USER_ID, val)
export const getUserId = () => localStorage.getItem(HMTT_USER_ID)
export const removeUserId = () => localStorage.removeItem(HMTT_USER_ID)

// 搜索历史 - 多个
const HMTT_SEARCH_KEYWORD = 'HMTT_SEARCH_KEYWORD'
export const setSearchKeyword = (val) => localStorage.setItem(HMTT_SEARCH_KEYWORD, JSON.stringify(val))
export const getSearchKeyword = () => JSON.parse(localStorage.getItem(HMTT_SEARCH_KEYWORD)) || []
export const removeSearchKeyword = () => localStorage.removeItem(HMTT_SEARCH_KEYWORD)